// pages/mockexam/special/single/detail/index.js
var app = getApp();

Page({

    /**
     * 页面的初始数据
     */
    data: {
        options: {},
        list: [],
        questionList: [],
        optionList: [],
        listIndex: 0,
        listSize: 0,
        questionIndex: 0,
        qmaxSize: 0,
        qcount: 0,
        submitObj: {},
        flag: true,
        resultInfo: {},
        success: 0,
        error: 0,
        showButton: false,
        checked: false,
        sure: false,
        showImage: false,
        qtype: ['单选题', '多选题', '判断题', '阅读理解', '图片题', '音频题', '案例题'],
        answerarr:['','A','B','C','D','E','正确','错误'],
        //这个全局属性是用来区分 请求是从 课后练习 模拟考试 专项
        questionPageSource:'',
        answerstr:"",
        checkboxAnswerStr:[],
        //这个属性是为了根据不同的页面来源来切换不同的显示行为
        questionAnswerNumView:true,
        nextCourseHourseId:"",
        knowingType:"",
    },

    /**
     * 课后练习的请求
     */
    getCourseExeriseList: function(request_url,course_code,viewOptions){

        var _this = this
        var source = _this.data.questionPageSource;
        var userId = app.globalData.userInfo.id;
        var param={};
        if(viewOptions!=undefined){
            param={
                parentCode:course_code,
                courseId:viewOptions.courseId,
                requestSource:source
            }
        }else{
            param={
                parentCode:course_code
            }
        }
        app.paiRequest(request_url, param
           ).then(function(res) {

            var dataList = res.data.list[0].questList;

            //做一个友好的提示如果，当前没有题，则直接退回上一个界面
            if(dataList && dataList.length==0){
                wx.showModal({
                    title: '提示',
                    content: '题库中未录入相关题库，请联系管理员。',
                    success (res) {
                        if (res.confirm) {
                            wx.navigateBack({
                                delta: 1
                            })
                        } else if (res.cancel) {
                            wx.navigateBack({
                                delta: 1
                            })
                        }
                    }
                })

            }

            _this.setData({
                qmaxSize: res.data.maxSize
            })

            //2020年5月14日21:46:19
           var  tempIndex = wx.getStorageSync("question_index_"+source+"_"+userId);
            debugger
            if(tempIndex == res.data.maxSize-1){
                _this.setData({
                    showButton: true
                })

            }


            for (let i = 0; i < dataList.length; i++){
                let str = dataList[i].objAnswer
                let arr = str.split(',')
                let arr1 = []
                let str1 = ''
                for(let j=0;j<arr.length;j++){
                    arr1.push(_this.data.answerarr[arr[j]])
                }
                str1 = arr1.join(',')
                dataList[i].answerstr = str1
            }
            var knowledge_point_type_index=0;
            try{

                knowledge_point_type_index = wx.getStorageSync("question_index_"+source+"_"+userId);

                if (knowledge_point_type_index>0){
                    console.log("记录不存在");
                }else{
                    knowledge_point_type_index=0;
                }
            }catch(e){
                knowledge_point_type_index=0;
            }

            _this.setData({
                list: dataList,
                listSize: dataList.length,
                // options: options,
                success: dataList.success,
                error: dataList.error,
                listIndex: knowledge_point_type_index
            })

            wx.hideLoading()

        })
    },

    /**
     * 生命周期函数--监听页面加载
     * 2020年4月23日21:06:10
     * 这里把题的展现形式和逻辑都整理到这个页面。
     */
    onLoad: function(options) {
      debugger
        //获取对应的习题名称
        var _this = this;
        //选择的问题有三种类型 课后练习 courseExerise 模拟考试 exam 专项练习 exerise
        //2020年4月26日 新增错题集合和收藏题

        var request_url, courseCode, questionPageSource,nextCourseHourseId;
        //2020年4月27 下一个课时的ID 用于解锁
        nextCourseHourseId = options.nextCourseHoursId;
        var userId = app.globalData.userInfo.id;
        _this.setData({
            nextCourseHourseId: nextCourseHourseId
        })

        questionPageSource = options.questionPageSource;
        courseCode = options.parentCode;
        if (questionPageSource){
            //课后练习
            if (options.questionPageSource==="courseExerise"){
                //根据不同类型显示不同的名字
                var temp_option = options;
                temp_option.objName=options.coursetitle+"练习题："

                _this.setData({
                    options: temp_option,
                    questionPageSource: options.questionPageSource,
                    //不显示打对打错
                    questionAnswerNumView:false,
                   
                })
                request_url = "/app/course/tcourses/exercisesNew";
                courseCode = courseCode;
                let viewOptions =undefined;
                this.getCourseExeriseList(request_url,courseCode,viewOptions)
            }
            else if(options.questionPageSource === "mine"){
                //根据不同类型显示不同的名字
                var temp_option = options;
                temp_option.objName=options.coursetitle+"练习题："

                _this.setData({
                    options: temp_option,
                    questionPageSource: options.questionPageSource,
                    //不显示打对打错
                    questionAnswerNumView:false,
                    //因为是个人纪录，直接回显答案
                    sure: false,
                    showImage: true,


                })
                request_url = "/app/course/tcourses/exercisesNew";
                courseCode = courseCode;
                let viewOptions = options;
                this.getCourseExeriseList(request_url,courseCode,viewOptions)
            }
            //专项练习的入口
            else if (options.questionPageSource === "exerise"){
                request_url = "/app/question/findList";
              
                
                wx.showLoading({
                    title: '',
                    mask: true
                })
                var _this = this;
                //  /app/question/findList
                app.paiRequest(request_url, {
                    knowledgePointType: options.knowledge_point_type

                }).then(function(res) {
                    var dataList = res.data;

                    for (let i = 0; i < dataList.list.length; i++){
                        let str = dataList.list[i].objAnswer
                        let arr = str.split(',')
                        let arr1 = []
                        let str1 = ''
                        for(let j=0;j<arr.length;j++){
                            arr1.push(_this.data.answerarr[arr[j]])
                        }
                        str1 = arr1.join(',')
                        dataList.list[i].answerstr = str1
                    }
                    var knowledge_point_type_index=0;
                    var konwingType = options.knowledge_point_type;
                    try{
                        knowledge_point_type_index = wx.getStorageSync("question_index_"+options.questionPageSource+konwingType+"_"+userId);
                        if(knowledge_point_type_index==""){
                            knowledge_point_type_index=0;
                        }

                    }catch(e){
                        knowledge_point_type_index=0;
                    }
                    var temp_options = options;
                     temp_options.objName ="习题"
                    _this.setData({
                        list: dataList.list,
                        listSize: dataList.length,
                        options: temp_options,
                        success: dataList.success,
                        error: dataList.error,
                        questionPageSource: options.questionPageSource,
                        listIndex: knowledge_point_type_index,
                        knowingType: konwingType
                    })

                    wx.hideLoading()
                    // var oneObj = dataList[0];
                    // app.paiRequest("/app/mockexam/special/single/listQuestion", {
                    //     id: oneObj.id
                    // }).then(function(ress) {

                    //     var childList = ress.data;
                    //     _this.setData({
                    //         questionList: childList,
                    //         qmaxSize: childList.length,
                    //         qcount: childList.length
                    //     })
                    // })
                })
            }
            else if (options.questionPageSource === "wrong"){
                var temp_option = options;
                temp_option.objName="错题："
                var userId= options.userId;
                _this.setData({
                    options: temp_option,
                    questionPageSource: options.questionPageSource,
                    //不显示打对打错
                    questionAnswerNumView:false,

                })
                let request_url = "app/question/findQuestionWrongList";
                let service_url = app.data.service_url;
                let url =service_url+request_url;

                this.getQuestion(url,userId)
            }
            else if (options.questionPageSource === "collections"){
               
                var temp_option = options;
                temp_option.objName="收藏："
                var userId= options.userId;

                _this.setData({
                    options: temp_option,
                    questionPageSource: options.questionPageSource,
                    //不显示打对打错
                    questionAnswerNumView:false,

                })
                var request_url = "app/question/findQuestionCollections";
                var service_url = app.data.service_url;
                var url =service_url+request_url;

                this.getQuestion(url,userId)
            }
        }


    },
    //收藏题和错题的获取题集合的方法
    getQuestion(url,userId){
        var tmep_arr = this.data.answerarr;
        var page_source = this.data.questionPageSource;
        var _this = this;
        var message;
        var time = new Date().getTime();
        wx.request({
            url: url+"?time="+time,
            method: "GET",
            data:{"userId":userId},
            success: function (res) {
                var dataList = res.data;
                _this.data.questionList = dataList;
                debugger
                if(page_source==="wrong"){
                    message = "请去做题、错题在这里显示。";
                }else{
                    message = "还未收藏题目,请去收藏题目。";
                }
             
                if(dataList && dataList.data.length==0){
                    wx.showModal({
                        title: '提示',
                        content:  message,
                        success (res) {
                            if (res.confirm) {
                                wx.navigateBack({
                                    delta: 1
                                })
                            } else if (res.cancel) {
                                wx.navigateBack({
                                    delta: 1
                                })
                            }
                        }
                    })

                }

                for (let i = 0; i < dataList.data.length; i++) {
                    let str = dataList.data[i].objAnswer
                    let arr = str.split(',')
                    let arr1 = []
                    let str1 = ''
                    for (let j = 0; j < arr.length; j++) {
                        arr1.push(tmep_arr[arr[j]])

                    }
                    str1 = arr1.join(',')
                    dataList.data[i].answerstr = str1
                }

                var knowledge_point_type_index = 0;
                try {
                    knowledge_point_type_index = wx.getStorageSync("question_index_"+page_source+"_"+userId);
                    if(knowledge_point_type_index==""){
                        knowledge_point_type_index=0;
                    }
                } catch (e) {
                    knowledge_point_type_index = 0;
                }

              if (dataList) {
                debugger
                if ((dataList.data.length-1) == knowledge_point_type_index) {
                  _this.setData({
                    showButton: true
                  })
                }
              }


                var options = {};
                options.objName = "习题：";

                _this.setData({
                    list: dataList.data,
                    listSize: dataList.data.length,
                    options: options,
                    success: dataList.success,
                    error: dataList.error,
                    listIndex: knowledge_point_type_index
                })

                wx.hideLoading()

            },
            fail: function (res) {

                wx.showToast({
                    title: '请求失败',
                    icon: 'none',
                    duration: 3000,
                    mask: false
                })
            }
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function() {

    },
    nextquestion: function() {
        this.setData({
            questionIndex: this.data.questionIndex + 1
        })
    },
    //抽取这个方法是为了上一题，下一题，维护不同的当前索引
    QuestionStroeIndexWithType: function (questionIndex, questionPageSource, userId) {
        if (questionIndex > 0) {
            wx.setStorageSync("question_index_" + questionPageSource + "_" + userId, questionIndex);
        } else {
            wx.setStorageSync("question_index_" + questionPageSource + "_" + userId, 0);
        }
    },
    upList: function() {
      //这里为了多选更好的逻辑判断，让没做题的不显示答案
      var temp_quesiton = this.data.list[this.data.listIndex-1];
      var question_type = temp_quesiton.objType;

      //如果是多选题
      if (question_type==1){
        if (temp_quesiton.answer1 != undefined) {
          //判断如果有属性 但是全是0，则也是没答题，不显示属性，但是题是错的
          if (temp_quesiton.answer1 === "0"
            && temp_quesiton.answer2 === "0"
            && temp_quesiton.answer3 === "0"
            && temp_quesiton.answer4 === "0"
            && temp_quesiton.answer5 === "0"
          ) {
            this.setData({
              sure: true,
              showImage: false
            })
          } else {
            this.setData({
              sure: false,
              showImage: true,
            })
          }
        }
        //不答题，则不显示
        else {
          //如果不存在，则证明未答题
          this.setData({
            showImage: false
          })
        }
      }else{ //单选或判断，用于显示答案
        if (!temp_quesiton.answer) {
          //如果不存在，则证明未答题
          this.setData({
            showImage: false
          })
        }
      }
     
       

        var questionIndex = this.data.listIndex;

        var userId = app.globalData.userInfo.id;
        var questionPageSource = this.data.questionPageSource;

        if (questionIndex > 0) {
            this.setData({
                listIndex: questionIndex - 1,
                showButton: false,
                answer1: 1
            })
            if(questionPageSource==="exerise"){
                var konwingType = options.knowledge_point_type;
                this.QuestionStroeIndexWithType(questionIndex - 1, questionPageSource+konwingType,userId);
            }else{
                this.QuestionStroeIndexWithType(questionIndex- 1, questionPageSource,userId);
            }
        } else {
            this.setData({
                listIndex: 0,
                answer1: 1
            })
            //维护跟用户相关的答题索引
            let questionIndex=0;
            if(questionPageSource==="exerise"){
                var konwingType = options.knowledge_point_type;
                this.QuestionStroeIndexWithType(questionIndex , questionPageSource+konwingType,userId);
            }else{
                this.QuestionStroeIndexWithType(questionIndex , questionPageSource,userId);
            }
        }
    },
    nextList: function() {
        var _this = this;
     
        var list = this.data.list;
        var listIndex = this.data.listIndex;

        //这里需要处理一下就一道题，同时点击下一题引起的索引异常边界判断
        var listSize = this.data.list.length;
        if(listSize==1){
            wx.showModal({
                title: '提示',
                content:  "这是最后一题，请问是否提交?",
                success (res) {
                    if (res.confirm) {

                        //调用提交的逻辑。
                        _this.submitQuestion()

                    } else if (res.cancel) {
                         return false;
                    }
                }
            })
        }

        var userId = app.globalData.userInfo.id;
        var questionPageSource = _this.data.questionPageSource;


        var temp_quesiton = _this.data.list[_this.data.listIndex + 1];
        var question_type = temp_quesiton.objType;
          //如果类型是1 就证明是多选题
        if (question_type == 1) {
            //如果没有该属性，则证明没答题
            if (temp_quesiton.answer1!=undefined){
              //判断如果有属性 但是全是0，则也是没答题，不显示属性，但是题是错的
              if (temp_quesiton.answer1 === "0"
                && temp_quesiton.answer2 === "0"
                && temp_quesiton.answer3 === "0"
                && temp_quesiton.answer4 === "0"
                && temp_quesiton.answer5 === "0"
              ) {
                _this.setData({
                  sure: true,
                  showImage: false
                })
              } else {
                _this.setData({
                  sure: false,
                  showImage: true,
                })
              }
            }
            //不答题，则不显示
            else {
              //如果不存在，则证明未答题
              _this.setData({
                showImage: false
              })
            }
        } else {
            if (!temp_quesiton.answer) {
              //如果不存在，则证明未答题
              _this.setData({
                showImage: false
              })
            }
        }
        //索引加1
        this.setData({
            listIndex: listIndex + 1,
            showButton: false,
        })
        //维护答题的索引,专项练习是按照知识类型又区分的题库。
        if(questionPageSource==="exerise"){
            var konwingType = _this.data.knowingType;
            this.QuestionStroeIndexWithType(listIndex + 1, questionPageSource+konwingType,userId);
        }else{
            this.QuestionStroeIndexWithType(listIndex + 1, questionPageSource,userId);
        }


        //最后判断 如果是最后一题，做逻辑处理
        var lastQueest = list[listIndex + 2]

        if (lastQueest == undefined) {
            this.setData({
              showButton: true,
              sure: false,
              showImage: false
            })
            //let listIndex = -1; //代表最后一题 索引重置为0
            //this.QuestionStroeIndexWithType(listIndex, questionPageSource,userId);
        }

          

    },

    radioChang: function(e) {
        var _this = this;
        var options = this.data.options;
        //证明是课后练习的请求，
        var request_url;

        var courseId,courseHouserId;
        var questionId = e.currentTarget.dataset.id;
        var postid = e.currentTarget.dataset.postid;
        var questionType = e.currentTarget.dataset.type;
        var answerId = e.detail.value;
        let arr1=[];
        arr1.push(_this.data.answerarr[answerId])
        let answerstr = arr1.join()

        // 统一请求体
        var questionParam;
        if (_this.data.questionPageSource ==="courseExerise"){
            questionParam = {
                courseId: options.courseId,
                courseHourseId: options.courseHourseId,
                questionId: questionId,
                answerId: answerId,
                questionType: questionType,
                userId: app.globalData.userInfo.id,
            }
            request_url ="/app/course/exercise/record/save";
        }
        //专项练习
        else if (_this.data.questionPageSource === "exerise"){
            questionParam = {
                specialId: options.parentCode,
                type: 'single',
                answerId: answerId,
                postId: postid,
                questionId: questionId,
                userId: app.globalData.userInfo.id,
            }
            request_url = "/app/mockexam/special/single/saveRecord";
        } else if (_this.data.questionPageSource === "exam") {
            request_url = "/app/mockexam/special/single/saveRecord";
        }






        let arr = this.data.list

        arr[this.data.listIndex].answer = answerId
        this.setData({
            list: arr,
            answerstr:answerstr
        })

        var _this = this;

        app.paiRequest(request_url, questionParam).then(function(res) {
            console.log(res);
            var data = res.data;
            var score = data.score;

            if (score == undefined) {

            } else {
                if (score > 0) {
                    _this.setData({
                        sure: true,
                        showImage: true,
                        success: data.success,
                        error: data.error
                    })
                } else {
                    //这里是错题，入错题库
                    //
                  


                  _this.setData({
                      sure: false,
                      showImage: true,
                      success: data.success,
                      error: data.error
                  })
                }
            }
        })
    },

    checkboxChang: function(e) {
        var _this = this;
        var value = e.detail.value;
        //这里追加逻辑
        //这里有重复录入的问题，所以做一次清空
      _this.data.checkboxAnswerStr = [];
        if (value.length > 0) {
            _this.data.checkboxAnswerStr.push(value)
        } else {
            _this.data.checkboxAnswerStr = [];
        }

        var temp_answer = _this.data.checkboxAnswerStr.join();

        var listIndex = this.data.listIndex;
        var postid = e.currentTarget.dataset.postid;
        var options = this.data.options;

        //根据不同的URL来进行后台的请求
        var request_url;
        if (_this.data.questionPageSource === "courseExerise") {
            request_url = "/app/course/exercise/record/save";
        } else if (_this.data.questionPageSource === "exerise") {
            request_url = "/app/mockexam/special/single/saveRecord";
        } else if (_this.data.questionPageSource === "exam") {
            request_url = "/app/mockexam/special/single/saveRecord";
        }

        var list = this.data.list;
        list[listIndex].answer1 = 0;
        list[listIndex].answer2 = 0;
        list[listIndex].answer3 = 0;
        list[listIndex].answer4 = 0;
        list[listIndex].answer5 = 0;
        for (var i = 0; i < value.length; i++) {
            var a = value[i];
            list[listIndex]['answer' + a] = a;
        }

        this.setData({
            list: list
        })

        // 下面去判断对错和是否显示解析
        var questionId = e.currentTarget.dataset.id;
        var type = e.currentTarget.dataset.type;

        let courseExerise = {
            courseId: options.courseId,
            courseHourseId: options.courseHourseId,
            questionId: questionId,
            answerId: temp_answer,
            questionType: type,
            userId: app.globalData.userInfo.id,
            postId:postid
        }
        app.paiRequest(request_url, courseExerise
        ).then(function(res) {
            console.log(res)
            var data = res.data;
            var score = data.score;
            var objAnswer = list[listIndex].objAnswer;
            if (objAnswer != undefined) {
                var answerArr = objAnswer.split(',');
                var show = false;

                for (var i = 0; i < value.length; i++) {
                    var char = value[i];
                    var ind = answerArr.indexOf(char);
                    //这里变更下逻辑,如果是多选题，只有点查看才显示
                    if (type=="1"){

                    }else{
                        if (ind < 0) {
                            show = true;
                        }
                    }

                }
                //这个就是查看的标志，如果查看标志true,则两个开关量都打开
                if (show) {
                    _this.setData({
                        sure: false,
                        showImage: true
                    })
                } else {
                    //这里的逻辑是如果如果其中一个选项为包含正确正确答案
                    // sure =true 不显示解析答案
                    _this.setData({
                        sure: true,
                        showImage: true
                    })
                }
                _this.setData({
                    success: data.success,
                    error: data.error
                })
            }
        })
    },


  //这里是点击查看，来查看解析答案
  savequestion:function(){
   
    this.setData({
      sure: false,
      showImage: true
    })
  },
    //结束
    submitQuestion: function() {
        var submitObj = this.data.submitObj;
        var _this = this;
        var options = this.data.options;
        var nextCourseHoursId = this.data.nextCourseHourseId;
        //结束的时候判断题的的对错状态，这个时候解锁



        //提交结束的借口
        let param,request_url;
        debugger
        if (_this.data.questionPageSource === "courseExerise") {
            request_url = "/app/course/tcourses/userExercises";
            param={
                courseId: options.courseId,
                courseHourseId: options.courseHourseId,
                exercisesId: options.exercisesId
            }
        } else if (_this.data.questionPageSource === "exerise") {
            request_url = "/app/mockexam/special/user/compute";
            param={
                specialId: options.parentCode,
                type: 'single',
                userSpecialId: options.singleId
            }
        }
        //如果是收藏,结束则需要回退
      if (request_url==undefined){
        wx.navigateBack({
          delta: 1
        })
      }else{
        app.paiRequest(request_url, param).then(function (res) {
            var userId = app.globalData.userInfo.id
           wx.setStorageSync("question_index_" + _this.data.questionPageSource  + "_" + userId, 0);
          //只有课后练习题才有解锁的概念
          if (_this.data.questionPageSource === "courseExerise") {
            var passStatus = res.data.passStatus;
            if (passStatus == true) {
              console.info("调用解锁接口")
              let unLockParam = {
                "courseId": options.courseId,
                "courseHourseId": _this.data.nextCourseHourseId
                //"userId":""
              }




              app.paiRequest("/app/course/tcourses/unlockCourseHour", unLockParam).then(function (res) {
                console.info("解锁成功")
              })
            }
          }



          var data = res.data;
          wx.navigateBack({
            delta: 2
          })

        })
        }
      
    },

    //收藏错题器
    saveCollections: function(e){
      
      var questionId = e.currentTarget.dataset.id;      
      let QuestionParam = {
        "questionId": questionId,
        "userId": app.globalData.userInfo.id
      }
      var _this=this;
      app.paiRequest("app/question/saveQuestionCollection", QuestionParam).then(function (res) {
        debugger
        var listIndex=_this.data.listIndex;
        var list=_this.data.list;
        var obj = list[listIndex];
        if(res.data==undefined){
          obj.collectFlag=true    
        }else{
          obj.collectFlag = res.data;
        }
        
        list[listIndex]=obj;
        _this.setData({
          list:list
        })        
      })
    },
    //取消收藏的
    cancelCollections:function(e){
        var _this=this;
        var questionId = e.currentTarget.dataset.id;
        var userId = app.globalData.userInfo.id;
        var questionPageSource = _this.data.questionPageSource;
        debugger
        var size = _this.data.questionList.data.length;

        let QuestionParam = {
            "questionId": questionId,
            "userId": userId
        }

      app.getRequest("app/question/deleteQuestionCollection", QuestionParam).then(function (res) {
          if(questionPageSource==="exerise"){
              var konwingType = _this.data.knowingType;
              var listIndex = knowledge_point_type_index = wx.getStorageSync("question_index_"+questionPageSource+konwingType+"_"+userId);
              if(size>1 && listIndex==0){
                  listIndex=0;
              }else if(size>1 && size==listIndex){
                  listIndex = listIndex-1;
              }else{
                  listIndex= listIndex;
              }
              _this.QuestionStroeIndexWithType(listIndex, questionPageSource+konwingType,userId);
          }else{
              var listIndex = wx.getStorageSync("question_index_"+questionPageSource+"_"+userId);
              if(size>1 && listIndex==0){
                  listIndex=0;
              }else if(size>1 && size==listIndex+1){
                  listIndex = listIndex-1;
              }else{
                  listIndex= listIndex;
              }
              _this.QuestionStroeIndexWithType(listIndex, questionPageSource,userId);
          }
          //上面的逻辑维护了 达到收藏题的索引。
          // 下面的逻辑是把当前的收藏题给取消掉
          var listIndex = _this.data.listIndex;
          var list = _this.data.list;
          list.splice(listIndex,1);
          _this.setData({
            list: list
          })
        var len = list.length;
        if(len==0){
          wx.navigateBack({
            delta: 1
          })
        }
        })
    },
    // 遮罩层隐藏
    conceal: function() {
        this.setData({
            flag: true
        })
        wx.navigateBack({
            delta: 1
        })
    },

  

})